package com.itheima.homework14;

public class Cun implements Runnable {

    @Override
    public void run() {
        while (true){
            int sum=0;
            synchronized (Store.obj) {
                if(Store.count>=10){
                    break;
                }else {

                    if(!Store.flag){
                        Store.count++;
                        sum+= Store.count;
                        System.out.println("生产存入"+"1"+"个单位货物"+",现在仓库剩余"+sum);
                        try {
                            Thread.sleep(100);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                            Store.obj.notifyAll();
                        }
                    }
                    else {
                        try {
                            Store.obj.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }

                }
            }
        }
    }
}
